 package tools;

 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;















 public class DateUtil
 {
   private static final int ITEM_YEAR2000 = -1085019342;
   private static final long REAL_YEAR2000 = 946681229830L;
   private static final int QUEST_UNIXAGE = 27111908;
   private static final long FT_UT_OFFSET = 116444520000000000L;

   public static long getTempBanTimestamp(long realTimestamp) {
/*  31 */     return realTimestamp * 10000L + 116444520000000000L;
   }







   public static int getItemTimestamp(long realTimestamp) {
/*  41 */     int time = (int)((realTimestamp - 946681229830L) / 1000L / 60L);
/*  42 */     return (int)(time * 35.762787D) + -1085019342;
   }







   public static int getQuestTimestamp(long realTimestamp) {
/*  52 */     int time = (int)(realTimestamp / 1000L / 60L);
/*  53 */     return (int)(time * 0.1396987D) + 27111908;
   }

   public static boolean isDST() {
/*  57 */     return TimeZone.getDefault().inDaylightTime(new Date());
   }







   public static long getFileTimestamp(long timeStampinMillis) {
/*  67 */     return getFileTimestamp(timeStampinMillis, false);
   }
   public static long getFileTimestamp(long timeStampinMillis, boolean roundToMinutes) {
     long time;
/*  71 */     if (isDST()) {
/*  72 */       timeStampinMillis -= 3600000L;
     }
/*  74 */     timeStampinMillis += 50400000L;

/*  76 */     if (roundToMinutes) {
/*  77 */       time = timeStampinMillis / 1000L / 60L * 600000000L;
     } else {
/*  79 */       time = timeStampinMillis * 10000L;
     }
/*  81 */     return time + 116444520000000000L;
   }

   public static int getTime() {
/*  85 */     String time = (new SimpleDateFormat("yyyy-MM-dd-HH")).format(new Date()).replace("-", "");
/*  86 */     return Integer.valueOf(time).intValue();
   }

   public static int getTime(long realTimestamp) {
/*  90 */     SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmm");
/*  91 */     return Integer.valueOf(sdf.format(Long.valueOf(realTimestamp))).intValue();
   }

   public static long getKoreanTimestamp(long realTimestamp) {
/*  95 */     return realTimestamp * 10000L + 116444592000000000L;
   }

   public static String getNowTime() {
/*  99 */     SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
/* 100 */     return sdf.format(new Date());
   }






   public static int getSpecialNowiTime() {
/* 109 */     return (int)(System.currentTimeMillis() % 100000000L);
   }











   public static String getCurrentDate() {
/* 123 */     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
/* 124 */     return sdf.format(new Date());
   }








   public static String getCurrentDate(String dateFormat) {
/* 135 */     SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
/* 136 */     return sdf.format(new Date());
   }







   public static String getFormatDate(Date date) {
/* 146 */     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
/* 147 */     return sdf.format(date);
   }








   public static String getFormatDate(Date date, String dateFormat) {
/* 158 */     SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
/* 159 */     return sdf.format(date);
   }










   public static String getPreDate(String field, int amount) {
/* 172 */     return getPreDate(new Date(), field, amount);
   }










   public static String getPreDate(Date d, String field, int amount) {
/* 185 */     Calendar calendar = Calendar.getInstance();
/* 186 */     calendar.setTime(d);
/* 187 */     if (field != null && !field.equals("")) {
/* 188 */       switch (field) {
         case "y":
/* 190 */           calendar.add(1, amount);
           break;
         case "M":
/* 193 */           calendar.add(2, amount);
           break;
         case "d":
/* 196 */           calendar.add(5, amount);
           break;
         case "H":
/* 199 */           calendar.add(10, amount);
           break;
       }
     } else {
/* 203 */       return null;
     }
/* 205 */     return getFormatDate(calendar.getTime());
   }








   public static String getPreDate(String date) throws ParseException {
/* 216 */     Date d = (new SimpleDateFormat()).parse(date);
/* 217 */     String preD = getPreDate(d, "d", 1);
/* 218 */     Date preDate = (new SimpleDateFormat()).parse(preD);
/* 219 */     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
/* 220 */     return sdf.format(preDate);
   }








   public static long getStringToTime(String dateString) {
/* 231 */     SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmm");
     try {
/* 233 */       Date date = df.parse(dateString);
/* 234 */       return date.getTime();
/* 235 */     } catch (Exception ex) {
/* 236 */       System.out.println(ex.getMessage());

/* 238 */       return -1L;
     }
   }
   public static long getStringToTime(String dateString, String format) {
/* 242 */     SimpleDateFormat df = new SimpleDateFormat(format);
     try {
/* 244 */       Date date = df.parse(dateString);
/* 245 */       return date.getTime();
/* 246 */     } catch (Exception ex) {
/* 247 */       System.out.println(ex.getMessage());

/* 249 */       return -1L;
     }
   }






   public static long getNextDayTime(int day) {
/* 259 */     Calendar date = Calendar.getInstance();
/* 260 */     date.set(date.get(1), date.get(2), date.get(5) + day, 0, 0, 0);
/* 261 */     return date.getTime().getTime();
   }







   public static long getNextDayDiff(int day) {
/* 271 */     Calendar date = Calendar.getInstance();
/* 272 */     date.set(date.get(1), date.get(2), date.get(5) + day, 0, 0);
/* 273 */     return date.getTime().getTime() - System.currentTimeMillis();
   }

   public static String getDayInt(int day) {
/* 277 */     if (day == 1)
/* 278 */       return "SUN"; 
/* 279 */     if (day == 2)
/* 280 */       return "MON"; 
/* 281 */     if (day == 3)
/* 282 */       return "TUE"; 
/* 283 */     if (day == 4)
/* 284 */       return "WED"; 
/* 285 */     if (day == 5)
/* 286 */       return "THU"; 
/* 287 */     if (day == 6)
/* 288 */       return "FRI"; 
/* 289 */     if (day == 7) {
/* 290 */       return "SAT";
     }
/* 292 */     return null;
   }

   public static Date getTuesDay() {
/* 296 */     Calendar instance = Calendar.getInstance();
/* 297 */     instance.set(7, 2);
/* 298 */     instance.set(11, 0);
/* 299 */     instance.set(12, 0);
/* 300 */     instance.set(13, 0);
/* 301 */     return instance.getTime();
   }

   public static boolean comparisonTime(long timeInMillis, long timeInMillis2) {
/* 305 */     Calendar instance = Calendar.getInstance();
/* 306 */     Calendar instance2 = Calendar.getInstance();
/* 307 */     instance.setFirstDayOfWeek(2);
/* 308 */     instance2.setFirstDayOfWeek(2);
/* 309 */     instance.setTimeInMillis(timeInMillis);
/* 310 */     instance2.setTimeInMillis(timeInMillis2);
     int n;
/* 312 */     if ((n = instance.get(1) - instance2.get(1)) == 0)
/* 313 */       return (instance.get(3) == instance2.get(3)); 
/* 314 */     if (n == 1 && instance2.get(2) == 11) {
/* 315 */       return (instance.get(3) == instance2.get(3));
     }
/* 317 */     return (n == -1 && instance.get(2) == 11 && instance.get(3) == instance2.get(3));
   }
 }